
import hashlib
import string
from pwn import *



def sha256_def(a,b):
    str = string.printable[:62]
    for i1 in str:
        for i2 in str:
            for i3 in str:
                for i4 in str:
                    a1 = i1 + i2 + i3 + i4
                    a2 = a1 + a
                    a2 = a2.encode()
                    if hashlib.sha256(a2).hexdigest() == b:
                        return a1


sh = remote("node4.buuoj.cn",29875)
sh.recvuntil("(",)
sh.recvuntil("+",)
a=sh.recvuntil(")",)[:-1].decode()
# print(a)

sh.recvuntil("== ",)
b=sh.recvuntil("\n",).decode().strip()
# print(b)

a1=sha256_def(a,b)
# print(a1)
sh.sendline(a1)

for i in range(777):
    sh.recvuntil("the ",)
    n1=sh.recvuntil("th",)[:-2].decode().strip()
    n2=str(int(n1)*4)
    sh.sendline(n2)
    (sh.recv())
sh.interactive()